package com.ljy.my_study.java.synch;

public class TestSynchronized {

    public static void main(String[] args) {

        new Thread(()->{
            new TestSynchronized().test1();
        }).start();
        new Thread(()->{
            new TestSynchronized().test1();
        }).start();

    }

    public static synchronized void test1(){
        System.out.println(Thread.currentThread().getName()+"执行test1方法 开始");
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"执行test1方法 结束");
    }
}
